package com.tuananh.radnom.model.thresholding;

import java.io.Serializable;
import java.util.ArrayList;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;

import org.eclipse.persistence.oxm.annotations.XmlClassExtractor;
import org.eclipse.persistence.oxm.annotations.XmlDiscriminatorNode;

import com.tuananh.radnom.model.netpoller.PollInfo;
import com.tuananh.radnom.model.notification.AbstractNotificator;

@XmlDiscriminatorNode("@class")
public abstract class AbstractThresholder implements Serializable {
	@XmlTransient
	public int getCurrentFail() {
		return currentFail;
	}
	public void setCurrentFail(int currentFail) {
		this.currentFail = currentFail;
	}

	String name;
	Severity severity;
	int toleranceTime;
	int currentFail = 0 ;
	String value;
	String dsName;
	ArrayList<AbstractNotificator> notificator;
	@XmlAttribute(name = "ds-name")
	public String getDsName() {
		return dsName;
	}

	public void setDsName(String dsName) {
		this.dsName = dsName;
	}
	@XmlElement(required=false)
	public ArrayList<AbstractNotificator> getNotificator() {
		return notificator;
	}
	public void setNotificator(ArrayList<AbstractNotificator> notificator) {
		this.notificator = notificator;
	}
	@XmlAttribute(name="compare-value",required=false)
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	@XmlAttribute(name="name",required=true)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@XmlAttribute(name="severity")
	public Severity getSeverity() {
		return severity;
	}
	public void setSeverity(Severity severity) {
		this.severity = severity;
	}
	@XmlAttribute(name="time")
	public int getToleranceTime() {
		return toleranceTime;
	}
	public void setToleranceTime(int toleranceTime) {
		this.toleranceTime = toleranceTime;
	}
	public abstract boolean compare(Object compareValue,PollInfo pollInfo,Object...args);
	
	public boolean populate(AbstractThresholder thresholder){
		this.notificator=(ArrayList<AbstractNotificator>) thresholder.notificator.clone();
		return true;
	}
	public abstract String printDetail(String extendInfo);
}
